#pragma once
#include "hash_table.h"


namespace lzz
{
	template<typename K, typename V>
	class unordered_map
	{
	private:
		template <typename K, typename V>
		struct mapKeyOfT
		{
			const K& operator()(const std::pair<const K, V>& kv) const
			{
				return kv.first;
			}
		};
		hash_bucket<K, std::pair<const K, V>, mapKeyOfT<K,V>> _hash;
	public:
		typedef typename hash_bucket<K, std::pair<const K, V>, mapKeyOfT<K, V>>::iterator iterator;
		typedef typename hash_bucket<K, std::pair<const K, V>, mapKeyOfT<K, V>>::const_iterator const_iterator;
		iterator begin() { return _hash.begin(); }
		iterator end() { return _hash.end(); }
		const_iterator begin() const { return _hash.begin(); }
		const_iterator end() const { return _hash.end(); }
		std::pair<iterator, bool> insert(const std::pair<const K, V>& kv) { return _hash.insert(kv); }
		V& operator[](const K& key)
		{
			auto ret = _hash.insert({ key, V() });
			return ret.first->second;
		}
		bool erase(const K& key) { return _hash.erase(key); }
		iterator find(const K& key) { return _hash.find(key); }
		const_iterator find(const K& key) const { return _hash.find(key); }
		void Print() { return _hash.print(); }
	};
}